import { Controller, Inject, Get, Query, Param, Del, Post } from '@midwayjs/core';
import { LoginInforService } from "@service/monitor/loginInfor.service";
import { ListLoginInforDTO } from "@dto/monitor/loginInfor.dto";
import { Auth } from "@decorator/auth.decorator";
import { BusinessType, Log } from "@decorator/log.decorator";

@Controller('/monitor/logininfor')
export class PostController {
  @Inject()
  loginInforService: LoginInforService;

  // 获取列表
  @Auth('monitor:logininfor:list')
  @Get('/list')
  async list(@Query() queryParams: ListLoginInforDTO) {
    return await this.loginInforService.list(queryParams);
  }

  // 删除
  @Auth('monitor:logininfor:remove')
  @Log({ title: '登录信息', businessType: BusinessType.REMOVE })
  @Del('/:infoId')
  async delete(@Param('infoId') infoId: string) {
    return await this.loginInforService.delete(infoId);
  }

  @Auth('monitor:logininfor:export')
  @Log({ title: '登录信息', businessType: BusinessType.EXPORT })
  @Post('/export')
  async export(@Query() queryParams: ListLoginInforDTO) {
    return await this.loginInforService.export(queryParams);
  }

  // 清空
  @Auth('monitor:logininfor:remove')
  @Log({ title: '登录信息', businessType: BusinessType.CLEAR })
  @Del('/clean')
  async clean() {
    return await this.loginInforService.clean();
  }

  // 获取列表
  @Auth('monitor:logininfor:unlock')
  @Get('/unlock/:userName')
  async unlock(@Param('userName') userName: string) {
    return await this.loginInforService.unlock(userName);
  }
}
